﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>StrLower / StrUpper / StrTitle - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The StrLower, StrUpper and StrTitle functions convert a string to lowercase, uppercase or title case." />
<meta name="ahk:equiv-v1" content="commands/StringLower.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>StrLower / StrUpper / StrTitle</h1>

<p>将字符串转换为小写, 大写, 或标题大小写.</p>

<pre class="Syntax">NewString := <span class="func">StrLower</span>(String)
NewString := <span class="func">StrUpper</span>(String)
NewString := <span class="func">StrTitle</span>(String)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>String</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>要转换的字符串.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
<p>这些函数返回指定字符串转换后的新版本.</p>

<h2 id="Remarks">备注</h2>
<p>要判断一个字符或字符串是完全大写还是小写, 请使用 <a href="Is.htm#upper">IsUpper</a>, <a href="Is.htm#lower">IsLower</a> 或 <a href="RegExMatch.htm">RegExMatch</a> 函数. 例如:</p>
<pre>var := "abc"
if isUpper(var)
    MsgBox "var is empty or contains only uppercase characters."
if isLower(var)
    MsgBox "var is empty or contains only lowercase characters."
if RegExMatch(var, "^[a-z]+$")
    MsgBox "var is not empty and contains only lowercase ASCII characters."
if !RegExMatch(var, "[A-Z]")
    MsgBox "var does not contain any uppercase ASCII characters."</pre>

<p><a href="Format.htm">Format</a> 也能实现大小写变换, 如下所示:</p>
<pre>MsgBox Format("{:U}, {:L} and {:T}", "upper", "LOWER", "title")</pre>

<h2 id="Related">相关</h2>
<p><a href="InStr.htm">InStr</a>, <a href="SubStr.htm">SubStr</a>, <a href="StrLen.htm">StrLen</a>, <a href="StrReplace.htm">StrReplace</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExLower">
<p><a class="ex_number" href="#ExLower"></a> 转换字符串为小写并将 "this is a test." 存储在 <var>String1</var>.</p>
<pre>String1 := "This is a test."
String1 := StrLower(String1)  <em>; 即输出可以和输入相同.</em></pre>
</div>

<div class="ex" id="ExUpper">
<p><a class="ex_number" href="#ExUpper"></a> 转换字符串为大写并将 "THIS IS A TEST." 存储在 <var>String2</var>.</p>
<pre>String2 := "This is a test."
String2 := StrUpper(String2)</pre>
</div>

<div class="ex" id="ExTitle">
<p><a class="ex_number" href="#ExTitle"></a> 转换字符串为标题大写并将 "This Is A Test." 存储在 <var>String3</var>.</p>
<pre>String3 := "This is a test."
String3 := StrTitle(String3, "T")</pre>
</div>

</body>
</html>